package org.shiwen.week5.Friday;

import static org.shiwen.week5.Friday.IsPrime.isPrime;

public class Q2 {
    public static void main(String[] args) {

        for (int i = 2; i <= 1000; i++) {
            if(i==2){
                System.out.print(i + " ");
                continue;
            }
            for (int j = 2; j <= i; j++) {
                //因为j从1开始循环，任何数字都可以整除1，所以不合理，应该从2开始循环
                if (i % j == 0) {
                    break;
                } else if (j==i-1) {
                    System.out.print(i + " ");
                }
            }
        }

        System.out.println();
        for (int j = 1; j <= 1000; j++) {
            if(isPrime(j)){
                System.out.print(j+ " ");
            }
        }
    }
}
